package cn.iocoder.yudao.module.form.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.form.dataobject.FormChoose;
import cn.iocoder.yudao.module.form.service.IFormChooseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 报选择Controller
 *
 * @author Fan KaiXiang
 * @date 2022-08-29
 */
@Api(tags = "a选择报表")
@RestController
@RequestMapping("/admin-api/form/choose")
public class FormChooseController
{
    @Autowired
    private IFormChooseService formChooseService;

    /**
     * 查询报表选择列表
     */
//    @PreAuthorize("@ss.hasPermi('system:choose:list')")
    @ApiOperation(value = "获取报表选择列表", notes = "获取报表选择列表")
    @GetMapping("/list")
    public CommonResult<List<FormChoose>> list(FormChoose formChoose)
    {
//        startPage();
        List<FormChoose> list = formChooseService.selectFormChooseList(formChoose);
        return success(list);
    }

    /**
     * 导出报表选择列表
     */
//    @PreAuthorize("@ss.hasPermi('system:choose:export')")
//    @Log(title = "报选择", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, FormChoose formChoose)
//    {
//        List<FormChoose> list = formChooseService.selectFormChooseList(formChoose);
//        ExcelUtil<FormChoose> util = new ExcelUtil<FormChoose>(FormChoose.class);
//        util.exportExcel(response, list, "报表选择数据");
//    }

    /**
     * 获取报表选择详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:choose:query')")
    @ApiOperation(value = "根据id获取报表选择", notes = "根据id获取报表选择列表")
    @GetMapping(value = "/{formId}")
    public CommonResult<FormChoose> getInfo(@PathVariable("formId") Long formId)
    {
        return success(formChooseService.selectFormChooseByFormId(formId));
    }


    /**
     * 新增报表选择
     */
//    @PreAuthorize("@ss.hasPermi('system:choose:add')")
    @ApiOperation(value = "新增报表选择", notes = "新增获取报表选择")
    @PostMapping
    public CommonResult<Integer> add(@RequestBody FormChoose formChoose)
    {
        return success(formChooseService.insertFormChoose(formChoose));
    }

    /**
     * 修改报表选择
     */
//    @PreAuthorize("@ss.hasPermi('system:choose:edit')")
    @ApiOperation(value = "修改报表选择", notes = "修改报表选择")
    @PutMapping
    public CommonResult<Integer> edit(@RequestBody FormChoose formChoose)
    {
        return success(formChooseService.updateFormChoose(formChoose));
    }

    /**
     * 删除报表选择
     */
//    @PreAuthorize("@ss.hasPermi('system:choose:remove')")
    @ApiOperation(value = "删除报表选择", notes = "删除报表选择")
	@DeleteMapping("/{formIds}")
    public CommonResult<Integer> remove(@PathVariable Long[] formIds)
    {
        return success(formChooseService.deleteFormChooseByFormIds(formIds));
    }
}
